//
//  HomeViewModel.swift
//  TodayNews
//
//  Created by ZhangBo on 2019/6/17.
//  Copyright © 2019 ZhangBo. All rights reserved.
//

import UIKit
import Moya

final class HomeViewModel: BaseViewModel {
    // MARK: 首页顶部新闻标题的数据
    func loadHomeNewsTitleData(completionHandler: @escaping (_ newsTitles: [HomeNewsTitle]) -> ()) {
        return
        let params = ["device_id": device_id, "iid": iid]
        homeNet.request(.newsTitles, param: params) {

        }
    }

    // MARK: 首页顶部导航栏搜索推荐标题内容
    func loadHomeSearchSuggestInfo(_ completionHandler: @escaping (_ searchSuggest: String) -> ()) {
        return
        let params = ["device_id": device_id, "iid": iid]
        homeNet.request(.searchSuggestInfo, param: params) {

        }
    }

    func test() {
        let provider = MoyaProvider<APIManager>()
        let params = ["device_id": device_id, "iid": iid]
        provider.request(.newsTitles(params)) { (result) in
            switch result {
            case .success(let response):
                print(response)
                do {
                    let any = try response.mapJSON()
                    print(any)
                } catch {
                    print(error)
                }
            case .failure(let error):
                print(error)
            }

        }
    }
}
